<?php
namespace app\admin\model\operating;
use think\facade\Db;
class News{
	
	public function insertAddNews($_data){
		return Db::name("news")->insert($_data);
	}
	
	public function findNewsData($_where,$_field)
	{
		return Db::name("news")->where($_where)->field($_field)->find();
	}
	
	public function updateNews($_up,$_where){
		return Db::name("news")->where($_where)->update($_up);
	}
	
	public function selectNewsData($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("news")->where($_where)->field($_field)->order($_order)->limit(current($_limit),next($_limit))->select();
		return empty($_data)?[]:$_data->toArray();
	}
	
	public function selectNewsComment($_where,$_field,$_limit,$_order){
		$_data=Db::name("news_comment")->alias("c")
			->join("user u","u.id=c.user_id")
			->where($_where)
			->field($_field)
			->order($_order)
			->limit(current($_limit),next($_limit))
			->select();
		return empty($_data)?[]:$_data->toArray();
	}
	
	public function updateNewsComment($_up,$_where)
	{
		return Db::name("news_comment")->where($_where)->update($_up);
	}
}
?>